package com.chinasofti.pool;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

public class MyThreadPoolDemo02 {
    public static void main(String[] args) {
        //1.创建一个默认的线程池对象
        ExecutorService extendedService = Executors.newFixedThreadPool(10);

        ThreadPoolExecutor pool = (ThreadPoolExecutor)extendedService;
        System.out.println(pool.getPoolSize());//0
        extendedService.submit(new Callable<Object>() {
            @Override
            public Object call() throws Exception {
             return Thread.currentThread().getState()+"在执行";
            }
        });
        extendedService.submit(()->{
            System.out.println(Thread.currentThread().getName()+"在执行");
            System.out.println(pool.getPoolSize());//2
        });
    }
}